Behavior selection algorithm